
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <div style="display: flex; align-items: center; justify-content: center;">
        <canvas id="canvas" width="1000" height="500"></canvas>
    </div>


    <script>
        const canvas = document.querySelector('#canvas')
        const ctx = canvas.getContext('2d')


        ctx.beginPath()
        ctx.moveTo(100,100)
        ctx.lineTo(200,150)
        ctx.lineTo(100,200)
        ctx.lineWidth = 10
        ctx.strokeStyle = 'red'
        // 设置尖角
        ctx.lineJoin = 'miter'
        ctx.stroke()


        ctx.beginPath()
        ctx.moveTo(200,100)
        ctx.lineTo(300,150)
        ctx.lineTo(200,200)
        ctx.lineWidth = 10
        ctx.strokeStyle = 'red'
        // 设置圆角
        ctx.lineJoin = 'round';
        ctx.stroke();

        ctx.beginPath();
        ctx.moveTo(300, 100);
        ctx.lineTo(400, 150);
        ctx.lineTo(300, 200);
        ctx.lineWidth = 10;
        ctx.strokeStyle = "red";
        // 设置斜角
        ctx.lineJoin = 'bevel';
        ctx.stroke();

        ctx.beginPath()
        ctx.moveTo(400,100)
        ctx.lineTo(500,100)
        ctx.lineWidth = 20
        ctx.strokeStyle = 'red'
        // 无
        ctx.lineCap = 'butt'
        ctx.stroke()

        ctx.beginPath();
        ctx.moveTo(400, 150);
        ctx.lineTo(500, 150);
        ctx.lineWidth = 20;
        ctx.strokeStyle = "red";
        // 圆
        ctx.lineCap = "round";
        ctx.stroke();

        ctx.beginPath();
        ctx.moveTo(400, 200);
        ctx.lineTo(500, 200);
        ctx.lineWidth = 20;
        ctx.strokeStyle = "red";
        // 方
        ctx.lineCap = "square";
        ctx.stroke();

    </script>
    
</body>
</html>